import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class FutureStrategyInstanceModel(BaseModel):
    """
    期货策略实例表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='策略实例id')
    server: Optional[str] = Field(default=None, description='服务器')
    group: Optional[str] = Field(default=None, description='组名')
    instance: Optional[str] = Field(default=None, description='实例名')
    class_name: Optional[str] = Field(default=None, description='类名')
    vt_symbol: Optional[str] = Field(default=None, description='合约代码')
    create_time: Optional[datetime.datetime] = Field(default=None, description='创建时间')
    update_time: Optional[datetime.datetime] = Field(default=None, description='更新时间')


@as_query
class FutureStrategyInstanceQueryModel(FutureStrategyInstanceModel):
    """
    期货策略实例管理不分页查询模型
    """
    pass


@as_query
class FutureStrategyInstancePageQueryModel(FutureStrategyInstanceQueryModel):
    """
    期货策略实例管理分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')
    sort_field: Optional[str] = Field(default=None, description='排序字段', alias='sortField')
    sort_order: Optional[str] = Field(default=None, description='排序方向', alias='sortOrder')


class DeleteFutureStrategyInstanceModel(BaseModel):
    """
    删除期货策略实例模型
    """

    instance_names: Optional[list[str]] = Field(default=None, description='策略实例名列表')
    ids: Optional[list[int]] = Field(default=None, description='策略实例ID列表')
